package bsf.baseservice.businessmq.dal;


import bsf.baseservice.businessmq.model.tb_consumer_client_model;
import bsf.db.DbConn;
import bsf.util.ConvertUtil;

import java.util.List;
import java.util.Map;

public class tb_consumer_client_dal
{

	public tb_consumer_client_model getByClient(DbConn PubConn, String client)
	{
			StringBuilder stringSql = new StringBuilder();
			stringSql.append("select top 1 s.* from tb_consumer_client s WITH(NOLOCK) where s.client=?");
		List<Map<String, Object>> ds =	PubConn.executeList(stringSql.toString(), new Object[]{client});
			if (ds != null && ds.size() > 0)
			{
				return createModel(ds.get(0));
			}
			return null;
	}

	public void add2(DbConn PubConn, String client)
	{
		 PubConn.executeSql("insert into tb_consumer_client(client,createtime) values(?,getdate())", new Object[]{client});
	}



	public tb_consumer_client_model createModel(Map<String, Object> dr)
	{
		tb_consumer_client_model o = new tb_consumer_client_model();

		//
		if (dr.containsKey("id"))
		{
			o.id= ConvertUtil.objToInt(dr.get("id"));
		}
		//�ͻ��ˣ�������client����ͬҵ��������ע�����һ�£�
		if (dr.containsKey("client"))
		{
			o.client= ConvertUtil.nullToStr(dr.get("client"));
		}
		//��ǰ�����ߴ���ʱ��(�Ե�ǰ��ʱ��Ϊ׼)
		if (dr.containsKey("createtime"))
		{
			o.createtime=ConvertUtil.objToDateTime(dr.get("createtime"));
		}
		return o;
	}
}